package com.ray3k.skincomposer.dialog.scenecomposer.undoables;

import com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposer;
import com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel;

public class ScrollPaneFadeScrollBarsUndoable implements SceneComposerUndoable {
    private DialogSceneComposerModel.SimScrollPane scrollPane;
    private DialogSceneComposer dialog;
    private boolean fadeScrollBars;
    private boolean previousfadeScrollBars;
    
    public ScrollPaneFadeScrollBarsUndoable(boolean fadeScrollBars) {
        this.fadeScrollBars = fadeScrollBars;
        dialog = DialogSceneComposer.dialog;
        scrollPane = (DialogSceneComposerModel.SimScrollPane) dialog.simActor;
        previousfadeScrollBars = scrollPane.fadeScrollBars;
    }
    
    @Override
    public void undo() {
        scrollPane.fadeScrollBars = previousfadeScrollBars;
        
        if (dialog.simActor != scrollPane) {
            dialog.simActor = scrollPane;
            dialog.populateProperties();
            dialog.populatePath();
        }
        dialog.model.updatePreview();
    }
    
    @Override
    public void redo() {
        scrollPane.fadeScrollBars = fadeScrollBars;
        
        if (dialog.simActor != scrollPane) {
            dialog.simActor = scrollPane;
            dialog.populateProperties();
            dialog.populatePath();
        }
        dialog.model.updatePreview();
    }
    
    @Override
    public String getRedoString() {
        return "Redo \"ScrollPane fade scroll bars " + fadeScrollBars + "\"";
    }
    
    @Override
    public String getUndoString() {
        return "Undo \"ScrollPane fade scroll bars " + fadeScrollBars + "\"";
    }
}
